package math;

/*
 *@description 回文数
 *@author hkfan
 *@version 1.0
 *@create 2025/6/18 15:58
 */
public class LeetCode_9 {
    public boolean isPalindrome(int x) {
        if (x<0){
            return false;
        }
        return reverse(x)==x;
    }

    private int reverse(int x) {
        Boolean flag = (x<0)?false:true;
        int res = 0;
        x = flag?x:-x;
        while (x!=0){
            res=res*10+x%10;
            x/=10;
        }
        return flag?res:-res;
    }
}
